//封装
//创建一个类
var book = function(id,bookname,bookprice) {
    this.id = id
    this.bookname = bookname
    this.bookprice = bookprice
}
//在类的原型上添加方法
//way1
book.prototype.display = function (params) {
    
}
//way2
book.prototype = {
    datail:function name(params) {
        return 'datail'
    }
}
//通过this添加的方法和prototype 添加的方法有什么不同？
 var book1 = new book (1,'gg',34)
 console.log(book1)
 console.log(book1.datail())


 function Person(name,age){
    this.name=name;
    this.age=age;
 }

 Person.prototype.eat=function(){
    console.log("Person 吃饭")
 }

 function Student(num,score){
    this.num=num
    this.score=score
 }

 //继承
Student.prototype=new Person("小红",10)
//Student.prototype.constructor=Student
Student.prototype.sayhi = function (params) {
    console.log('hi')
}

var stu =new Student(2016002288,80)

stu.eat()//Person 吃饭
stu.sayhi()